<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div style="width: 300px; height: 180px; background-color: red"></div>
    <div style="
        width: 300px;
        height: 180px;
        background-color: green;
        visibility: hidden;
      "></div>
    <div style="
        width: 300px;
        height: 180px;
        background-color: blue;
        visibility: visible;
      "></div>

    <!-- display: none; 不会占据原有的空间 -->
    <!-- visibility: hidden; 会占据原有的空间 -->
</body>

</html>